<template>
    <div class="mine">
        <div class="mine-top">
            <div class="mine-box">
                <div class="mine-info">
                    <!-- <img src="../../../public/img/header.png" alt=""> -->
                    <uploading></uploading>
                    <div class="mine-info-right">
                        <div class="r1">
                            <h4 v-if="userInfo.mobile?true:false">{{userInfo.mobile}}</h4>
                            <h5 v-else @click="gotologin">请登录</h5>
                            <van-icon name="setting-o" size="20px" @click="show=!show" v-if="userInfo.mobile?true:false" />
                        </div>
                    
                        <div class="r2" v-if="userInfo.mobile?true:false"> 
                            <div class="member" >
                                <van-icon name="gem-o"  /> 普通会员  
                            </div>

                            <span>积分:200</span> 
                        </div>
                        <span class="yaoqing" v-if="userInfo.mobile?true:false">邀请码: 33333 <span class="copy">复制</span> </span>
                    </div>
                </div>

            </div>
        </div>
        <div class="mine-main-box" v-if="userInfo.mobile?true:false">
            <div class="mmbox">
                <div class="mmbox-head">
                    <p>我的订单</p>
                    <span>查看全部订单 <van-icon name="arrow" /></span>
                </div>
                <div class="mmbox-body">
                    <div class="body-one">
                        <i class="iconfont icon-qianbao"></i>
                        <h5>Pending</h5>
                        <p>待付款</p>
                    </div>
                    <div class="body-one">
                        <i class="iconfont icon-dabao"></i>
                        <h5>Processing</h5>
                        <p>待发货</p>
                    </div>
                    <div class="body-one">
                        <i class="iconfont icon-baoguo"></i>
                        <h5>Deliver</h5>
                        <p>待收货</p>
                    </div>
                    <div class="body-one">
                        <i class="iconfont icon-danzi"></i>
                        <h5>Complete</h5>
                        <p>已完成</p>
                    </div>
                </div>
            </div>

            <div class="mmbox mmbox2">
                <div class="mmbox-head">
                    <p>我的服务</p>
                </div>
                <div class="mmbox-body">
                    <div class="body-one type2">
                        <i class="iconfont icon-dizhi"></i>
                        <h5>Address</h5>
                        <p>我的地址</p>
                    </div>
                    <div class="body-one type2">
                        <i class="iconfont icon-piaowu"></i>
                        <h5>Coupon</h5>
                        <p>我的优惠券</p>
                    </div>
                    <div class="body-one type2">
                        <i class="iconfont icon-jifen"></i>
                        <h5>Points</h5>
                        <p>我的积分</p>
                    </div>
                    <div class="body-one type2">
                        <i class="iconfont icon-zuji"></i>
                        <h5>History</h5>
                        <p>足迹</p>
                    </div>
                    <div class="body-one type2">
                        <i class="iconfont icon-shoucang"></i>
                        <h5>Favorite</h5>
                        <p>我的收藏</p>
                    </div>
                    <div class="body-one type2">
                        <i class="iconfont icon-qingguan"></i>
                        <h5>Infomation</h5>
                        <p>清关信息</p>
                    </div>
                </div>
            </div>
        </div>

        <van-action-sheet
        v-model="show"
        :actions="actions"
        cancel-text="退出当前帐号"
        close-on-click-action
        @cancel="onCancel"
        title="设置"
        closeable
        />
        
        
        <Foot></Foot>
    </div>
</template>


<script>
import {mapState,mapMutations} from 'vuex';
import { Form, Notify } from 'vant'
import uploading from '../../components/uploading.vue';
export default {
  components: { uploading },
    data(){
        return{
            phone:'',
            show: false,
            actions: [{ name: '昵称' }, { name: '邮箱' }, { name: '我的手机号' }],
        }
    },
    methods:{
        gotologin(){
            this.$router.push({name:'login'})
        },
        onCancel(){
            localStorage.clear('mobile')
            this.$router.push({name:'login'})
            Notify({ type: 'warning', message: "已退出当前帐号" });
        },
        ...mapMutations(['setUserInfo'])
    },
    mounted(){
        this.phone=localStorage.getItem('mobile')
        this.$ajax.getuserinfo().then(res=>{
            if(res.code==200){
                // console.log(res)
                this.setUserInfo(res.result)
            }
        })
    },
    computed:{
        ...mapState(['userInfo'])
    },
}
</script>


<style lang="scss" scoped>
    .mine{
        .mine-top{
            width: 100%;
            height: 180px;
            background: url('../../../public/img/my-bg.jpg') no-repeat;
            background-size: 100% 100%;
        }
        .mine-box{
            padding: 0 24px;
            .mine-info{
                display: flex;
                color: white;
                padding-top: 36px; 
                img{
                    width: 60px;
                    height: 60px;
                    margin-top: 24px;
                }
                .mine-info-right{
                    margin-top: 12px;
                    margin-left: 12px;
                    flex: 1;
                    h4{
                        margin-bottom: 12px;
                        font-size: 17px;
                    }
                    h5{
                        font-size: 17px;
                        padding-top: 30px;
                        padding-left: 15px;
                    }
                    .r1{
                        display: flex;
                        justify-content: space-between;
                        font-size: 12px;
                        
                    }
                    .r2{
                        margin-top: 3px;
                        display: flex;
                        justify-content: space-between;
                        span{
                            width: 60px;
                            height: 16px;
                            display: block;
                            background-color: #fff;
                            color: #333333;
                            padding: 3px 6px;
                            border-radius: 40px;
                            text-align: center;
                        }
                    }
                    .yaoqing{
                        display: inline-block;
                        margin-top: 10px;
                        padding: 5px;
                        padding-left: 9px ;
                        padding-right: 0;
                        line-height: 17px;
                        border: 1px solid white;
                        border-radius: 15px;
                        .copy{
                            padding: 5px 10px;
                            margin-left: 5px;
                            border: 1px solid white;
                            border-radius: 15px;
                            text-align: center;
                            
                        }
                    }
                }
            }
        }
        .mine-main-box{
            padding: 0 24px;
            // margin-bottom: 50px;
            position: absolute;
            top:155px ;

            padding-bottom: 80px;
            
            .mmbox2{
                margin-top: 25px;
            }
            
            .mmbox{
               
                color: #333333;
                background-color: #fff;
                border-radius: 10px;
                box-shadow: 0 0.09rem 0.2rem -0.1rem rgba(80,80,80,.3);
                .mmbox-head{
                display: flex;
                justify-content: space-between;
                border-bottom: 2px solid #c8c8cd;
                p{
                    padding: 12px;
                    font-size: 18px;
                    font-weight: bold;
                }
                span{
                    padding: 12px;
                    font-size: 16px;
                    
                }
            }
            .mmbox-body{
               
                width: 100%;
                display: flex;
                flex-wrap: wrap;
                padding: 12px;
                justify-content: space-between;
                box-sizing: border-box;
                .body-one{
                    width: 20%;
                    display: flex;
                    flex-direction: column;
                    
                    justify-content: center;
                    align-items: center;
                    i{
                        padding: 12px;
                        font-size: 30px;
                    }
                }
                .type2{
                    width: 30%;
                }
                
            }
        }
            
            
        }
    }
    .van-action-sheet__cancel{
        color: red;
    }
    .van-action-sheet__header{
        font-weight: 600;
        font-size: 16px;
        border-bottom: 3px solid #f6f6f6;
        
    }
    .van-action-sheet__close{
        display: none;
    }
</style>